import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SWFInfo } from "../../../../com/gengine/resource/info/SWFInfo";
import { ObjCreate } from "../common/ObjCreate";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { SkyCityEnterRender } from "./SkyCityEnterRender";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { DataProvider } from "../../../../fl/data/DataProvider";
type int = number;
//class SkyCityEnterWindow
    
    export  class SkyCityEnterWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(679, 464);
            titleHeight = 26;
            title = Language.getString(44000);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SkyCityRequestList));
            return;
        }

        protected /* override */ createChildren(): void
        {
            var bgskyCity: Object /* flash.display.Bitmap */;
            var onLoadedComplete: Function;
            var tipsTextFormat: Object /* flash.text.TextFormat */;
            var tfTips: Object /* flash.text.TextField */;

            var loc1;
            bgskyCity = null;
            onLoadedComplete = null;
            onLoadedComplete = (arg1: SWFInfo): void
            {
                bgskyCity.bitmapData = arg1.bitmapData;
                return;
            }
            super.createChildren();
            ObjCreate.createBg(18, 38, 643, 337, this);
            bgskyCity = new Object /* flash.display.Bitmap */();
            bgskyCity.x = 19;
            bgskyCity.y = 39;
            this.addChild(bgskyCity);
            LoaderManager.instance.load("peaceFieldBg.swf", onLoadedComplete);
            this._skyCityTilelist = new GTileList();
            this._skyCityTilelist.setSize(590, 246);
            this._skyCityTilelist.columnWidth = 118;
            this._skyCityTilelist.rowHeight = 123;
            this._skyCityTilelist.direction = ScrollBarDirection.VERTICAL;
            this._skyCityTilelist.horizontalGap = 0;
            this._skyCityTilelist.verticalGap = 0;
            this._skyCityTilelist.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._skyCityTilelist.setStyle("cellRenderer", SkyCityEnterRender);
            this._skyCityTilelist.x = 30;
            this._skyCityTilelist.y = 60;
            this.addChild(this._skyCityTilelist);
            this._pageSelecter = new PageSelecter();
            this._pageSelecter.mode = PageSelecter.CompleteMode;
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChange);
            ObjCreate.setObjAttri(this._pageSelecter, 278, 334, -1, -1, this);
            tipsTextFormat = new GTextFormat(FontUtil.songtiName, 12, 6350622);
            tipsTextFormat.leading = 5;
            tfTips = ObjCreate.createTextField("", 18, 380, 440, 78, this, tipsTextFormat);
            tfTips.multiline = true;
            tfTips.wordWrap = true;
            tfTips.htmlText = Language.getString(44001);
            return;
        }

        public updateList(arg1: Array<any>): void
        {
            this._fields = arg1;
            this._pageSelecter.currentPage = 1;
            this._pageSelecter.maxPage = Math.ceil(this._fields.length / this.PageSize);
            this.updateFieldsByPage();
            return;
        }

        /* internal  */onChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateFieldsByPage();
            return;
        }

        /* internal  */updateFieldsByPage(): void
        {
            var loc1=(this._pageSelecter.currentPage - 1) * this.PageSize;
            var loc2=Math.min(loc1 + this.PageSize, this._fields.length);
            var loc3=new Array<any>();
            var loc4=loc1;
            while (loc4 < loc2) 
            {
                loc3.push(this._fields[loc4]);
                ++loc4;
            }
            this._skyCityTilelist.dataProvider = new DataProvider(loc3);
            return;
        }

        /* internal */ /* var */_skyCityTilelist: GTileList;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */PageSize: int=10;

        /* internal */ /* var */_fields: Array<any>;
    }
